﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace Future.FormBase
{
    /// <summary>
    /// 每个子窗体的按钮列表
    /// </summary>
    public class ButtonList : IButtonList
    {
        private IList _Buttons = new ArrayList();


        #region IButtonList 成员

        public void AddRange(IButtonInfo[] buttons)
        {
            foreach (IButtonInfo btn in buttons)
                if (btn != null)
                    this._Buttons.Add(btn);
        }

        public void AddRange(IList buttons)
        {
            foreach (IButtonInfo btn in buttons)
                if (btn != null)
                    this._Buttons.Add(btn);
        }

        public IButtonInfo GetButtonByName(string name)
        {
            foreach (IButtonInfo b in _Buttons)
                if (b.Name == name) return b;
            return new NullButton();
        }

        public IButtonInfo[] ToArray()
        {
            IButtonInfo[] ret = new IButtonInfo[_Buttons.Count];
            for (int i = 0; i <= _Buttons.Count - 1; i++)
                ret[i] = (IButtonInfo)_Buttons[i];
            return ret;
        }

        public IList ToList()
        {
            return _Buttons;
        }

        #endregion
    }
}
